home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
et
/
src
/
range.c
< prev
next >
Wrap
Text File
|
1993-07-08
|
9KB
|
330 lines
#include "et.h"
void init_range(int mm)/*et*/
{
int *range_p, *range_b_p;
void (**func_p)(), (**func_b_p)();
switch(mm) {
case 0:
range_p = P_i[i_WIN_RANGE];
range_b_p = P_i[i_WIN_RANGE_B];
func_p = &G_pn.range;
func_b_p = &G_pn.range_b;
break;
case _LT:
range_p = P_i[i_WIN_RANGE_LT];
range_b_p = P_i[i_WIN_RANGE_LT_B];
func_p = &G_pn.range_lt;
func_b_p = &G_pn.range_lt_b;
break;
case _RT:
range_p = P_i[i_WIN_RANGE_RT];
range_b_p = P_i[i_WIN_RANGE_RT_B];
func_p = &G_pn.range_rt;
func_b_p = &G_pn.range_rt_b;
break;
}
if (*func_p) {
(*func_p)(P_RES, range_p, mm);
*func_b_p = *func_p;
_copy_buf(range_b_p, range_p, sizeof(int[4]));
}
range_p[0] = range_p[1] = 10000;
range_p[2] = range_p[3] = -10000;
}
void set_range(int pq_a[], int mm)/*et*/
{
int p_low, p_upp, q_low, q_upp;
int *range_p;
switch(mm) {
case 0:
range_p = P_i[i_WIN_RANGE];
break;
case _LT:
range_p = P_i[i_WIN_RANGE_LT];
break;
case _RT:
range_p = P_i[i_WIN_RANGE_RT];
break;
}
if (pq_a[0] < pq_a[2]) {
p_low = pq_a[0];
p_upp = pq_a[2];
} else {
p_low = pq_a[2];
p_upp = pq_a[0];
}
if (pq_a[1] < pq_a[3]) {
q_low = pq_a[1];
q_upp = pq_a[3];
} else {
q_low = pq_a[3];
q_upp = pq_a[1];
}
if (range_p[0] > p_low)
range_p[0] = p_low;
if (range_p[2] < p_upp)
range_p[2] = p_upp;
if (range_p[1] > q_low)
range_p[1] = q_low;
if (range_p[3] < q_upp)
range_p[3] = q_upp;
}
void cul_range(int mm)/*et*/
{
unsigned f_1, f_2;
int *range_p, *frame_p;
void (**func_p)();
switch(mm) {
case 0:
range_p = P_i[i_WIN_RANGE];
func_p = &G_pn.range;
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
range_p = P_i[i_WIN_RANGE_LT];
func_p = &G_pn.range_lt;
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_LT];
break;
case _RT:
range_p = P_i[i_WIN_RANGE_RT];
func_p = &G_pn.range_rt;
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_RT];
break;
}
do {
if (range_p[0] == 10000)
if (range_p[1] == 10000)
if (range_p[2] == -10000)
if (range_p[3] == -10000) {
*func_p = draw_all_range;
continue;
}
f_1 = f_2 = 0;
if (range_p[0] < frame_p[0])
set_bit(f_1, 1);
else if (range_p[0] > frame_p[2])
set_bit(f_1, 2);
if (range_p[2] < frame_p[0])
set_bit(f_2, 1);
else if (range_p[2] > frame_p[2])
set_bit(f_2, 2);
if (range_p[1] < frame_p[1])
set_bit(f_1, 4);
else if (range_p[1] > frame_p[3])
set_bit(f_1, 8);
if (range_p[3] < frame_p[1])
set_bit(f_2, 4);
else if (range_p[3] > frame_p[3])
set_bit(f_2, 8);
if (range_p[0] < frame_p[0])
range_p[0] = frame_p[0];
if (range_p[2] > frame_p[2])
range_p[2] = frame_p[2];
if (range_p[1] < frame_p[1])
range_p[1] = frame_p[1];
if (range_p[3] > frame_p[3])
range_p[3] = frame_p[3];
switch(f_1 & f_2) {
case 1:
*func_p = draw_p_low_range;
break;
case 2:
*func_p = draw_p_upp_range;
break;
case 4:
*func_p = draw_q_low_range;
break;
case 8:
*func_p = draw_q_upp_range;
break;
case 5:
range_p[0] = frame_p[0]-5;
range_p[1] = frame_p[1]-5;
range_p[2] = frame_p[0]-2;
range_p[3] = frame_p[1]-2;
*func_p = draw_out;
break;
case 9:
range_p[0] = frame_p[0]-5;
range_p[1] = frame_p[3]+1;
range_p[2] = frame_p[0]-2;
range_p[3] = frame_p[3]+4;
*func_p = draw_out;
break;
case 10:
range_p[0] = frame_p[2]+1;
range_p[1] = frame_p[3]+1;
range_p[2] = frame_p[2]+4;
range_p[3] = frame_p[3]+4;
*func_p = draw_out;
break;
case 6:
range_p[0] = frame_p[2]+1;
range_p[1] = frame_p[1]-5;
range_p[2] = frame_p[2]+4;
range_p[3] = frame_p[1]-2;
*func_p = draw_out;
break;
default:
*func_p = draw_pq_range;
break;
}
} while (0);
if (test_bit(G_f, f_GPH))
G_nb.col = H_MZN;
else if (test_bit(G_f, f_EE))
G_nb.col = set_key_col();
else if (test_bit(G_f, f_TT))
G_nb.col = H_SYN;
else
G_nb.col = H_RED;
(*func_p)(P_SET, range_p, mm);
}
void cls_frame(int pq_a[], int i, int col, int line_m)/*et*/
{
draw_line(pq_a[0]+i-1, pq_a[1]+i-1, pq_a[2]-i, pq_a[1]+i-1, col, line_m);
draw_line(pq_a[0]+i-1, pq_a[1]+i-1, pq_a[0]+i-1, pq_a[3]-i, col, line_m);
draw_line(pq_a[2]-i, pq_a[1]+i-1, pq_a[2]-i, pq_a[3]-i, col, line_m);
draw_line(pq_a[2]-i, pq_a[3]-i, pq_a[0]+i-1, pq_a[3]-i, col, line_m);
}
void draw_all_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -4; i <= -1; i++) {
cls_frame(P_i[i_WIN_VIEW], i, H_WHT, P_RES);
if (i >= -3 && i <= -2)
cls_frame(P_i[i_WIN_VIEW], i, col, line_m);
}
}
void draw_p_low_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
int *frame_p;
if (pq_a[1]>500||pq_a[3]<0)
return;
switch(mm) {
case 0:
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_LT];
break;
case _RT:
return;
}
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -3; i <= -2; i++)
draw_line(frame_p[0]+i-1,pq_a[1],frame_p[0]+i-1,pq_a[3],col,line_m);
}
void draw_p_upp_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
int *frame_p;
if (pq_a[1]>500||pq_a[3]<0)
return;
switch(mm) {
case 0:
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
return;
case _RT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_RT];
break;
}
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -3; i <= -2; i++)
draw_line(frame_p[2]-i,pq_a[1],frame_p[2]-i,pq_a[3],col,line_m);
}
void draw_q_low_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
int *frame_p;
if (pq_a[0]>500||pq_a[2]<0)
return;
switch(mm) {
case 0:
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_LT];
break;
case _RT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_RT];
break;
}
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -3; i <= -2; i++)
draw_line(pq_a[0],frame_p[1]+i-1,pq_a[2],frame_p[1]+i-1,col,line_m);
}
void draw_q_upp_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
int *frame_p;
if (pq_a[0]>500||pq_a[2]<0)
return;
switch(mm) {
case 0:
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_LT];
break;
case _RT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_RT];
break;
}
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -3; i <= -2; i++)
draw_line(pq_a[0],frame_p[3]-i,pq_a[2],frame_p[3]-i,col,line_m);
}
void draw_out(int line_m, int pq_a[], int mm)/*et*/
{
int col;
if (pq_a[0]>500||pq_a[1]>500||pq_a[2]<0||pq_a[3]<0)
return;
col = (line_m == P_SET) ? G_nb.col : H_WHT;
draw_line(pq_a[0], pq_a[1], pq_a[2], pq_a[1], col, line_m);
draw_line(pq_a[2], pq_a[1], pq_a[2], pq_a[3], col, line_m);
draw_line(pq_a[2], pq_a[3], pq_a[0], pq_a[3], col, line_m);
draw_line(pq_a[0], pq_a[3], pq_a[0], pq_a[1], col, line_m);
}
void draw_pq_range(int line_m, int pq_a[], int mm)/*et*/
{
int i, col;
int *frame_p;
if (pq_a[0]>500||pq_a[1]>500||pq_a[2]<0||pq_a[3]<0)
return;
switch(mm) {
case 0:
frame_p = P_i[i_WIN_VIEW];
break;
case _LT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_LT];
break;
case _RT:
frame_p = (test_bit(G_f, f_GPH)) ? P_i[i_WIN_VIEW] : P_i[i_WIN_VIEW_RT];
break;
}
col = (line_m == P_SET) ? G_nb.col : H_WHT;
for (i = -3; i <= -2; i++) {
draw_line(pq_a[0],frame_p[1]+i-1,pq_a[2],frame_p[1]+i-1,col,line_m);
draw_line(pq_a[0],frame_p[3]-i,pq_a[2],frame_p[3]-i,col,line_m);
if (mm != _RT)
draw_line(frame_p[0]+i-1,pq_a[1],frame_p[0]+i-1,pq_a[3],col,line_m);
if (mm != _LT)
draw_line(frame_p[2]-i,pq_a[1],frame_p[2]-i,pq_a[3],col,line_m);
}
}